<%@ page import="com.uni.entity.User" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri = "http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
    <title>用户信息中心</title>
    <link rel="icon" href="img/weblogo.png" >
    <link rel="stylesheet" type="text/css" href="bootstrap-5.1.3-dist/css/bootstrap.min.css"/>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.7.2/font/bootstrap-icons.css">
    <link rel="stylesheet" type="text/css" href="css/ycc.css"/>
    <script type="text/javascript" src="js/jquery-3.6.0-min.js"></script>
    <script type="text/javascript" src="bootstrap-5.1.3-dist/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="js/card_user_publish_commodity.js"></script>
</head>
<body>

<div class="row">
    <!-- 显示浏览记录 -->
    <div class="col-md-12 div-card">
        <h3 class="h-title-black">
            <i class="bi bi-clock-history"></i>
            已发布的商品 共${sessionScope.publishInfo.size()}条
            <c:if test="${not empty sessionScope.publishInfo && sessionScope.publishInfo.size() > 0}">
                [${sessionScope.publishPageNow},${sessionScope.publishPageNow+1}] 条
            </c:if>
        </h3>
        <div class="row row-cols-1 row-cols-md-2 g-4">
            <c:set var="pageNow" scope="page" value="${sessionScope.publishPageNow}"></c:set>
            <c:forEach items="${sessionScope.publishInfo}" begin="${pageNow}" end="${pageNow + 1}" var="pb" varStatus="index">
                <c:if test="${index.index <= sessionScope.publishInfo.size()}">
                    <div class="card-commodity-row">
                        <div class="card-commodity" data-cid="${pb.id}">
                            <img src="${pb.img}" class="card-img-top">
                            <div class="card-body">
                                <h5 class="card-title text-center">￥${pb.price}</h5>
                                <h6>商品名称: <span>${pb.name}</span></h6>
                                <h6 class="card-text" href="#">商品类型: ${pb.typeName}</h6>
                                <a class="card-text" href="#">商品描述: ${pb.info}</a>
                            </div>
                            <div class="text-center">
                                <button id="bt-delete-commodity" class="btn btn-outline-danger w-50" style="margin-bottom: 10px" data-cid="${pb.id}">删除商品</button>
                            </div>
                        </div>
                    </div>
                </c:if>
            </c:forEach>
        </div>
        <c:if test="${sessionScope.publishInfo.size() <= 0}">
            <h5 class="mt-3 text-center">您暂未发布任何商品.</h5>
        </c:if>
        <c:if test="${sessionScope.publishInfo.size() > 0}">
            <nav aria-label="Page navigation example">
                <ul class="pagination justify-content-center">
                    <li class="page-item p-2"><a class="page-link text-black bg-warning" href="/publishPage">更多</a></li>
                </ul>
            </nav>
        </c:if>
    </div>
</div>

</body>
</html>